package uk.ac.aber.Blockmation.FileFilters;

import uk.ac.aber.Blockmation.FileManager;

import java.io.File;

import javax.swing.filechooser.FileFilter;


/**
 * Combined file filter for GIF, JPG, BMP and PNG extensions.
 *
 * @author Zuza
 */
public class ImageFileFilter extends FileFilter
{
    public ImageFileFilter()
    {
    }

    @Override
    public boolean accept(File f)
    {
        if (f.isDirectory())
        {
            return true;
        }

        String extension = FileManager.getExtFromFile(f);

        if (extension != null)
        {
            if (extension.equals("gif") || extension.equals("jpg") ||
                    extension.equals("bmp") || extension.equals("png"))
            {
                return true;
            }
            else
            {
                return false;
            }
        }

        return false;
    }

    @Override
    public String getDescription()
    {
        String filterDescription = "GIF, BMP, JPG or PNG files";

        return filterDescription;
    }
}
